% Author: Feng Sheng
% Study: Endowment Effect in Eyes

%% Setup
% Set this folder as the root folder
clear;
clc;
root_path=pwd;
addpath(genpath(root_path));

%% Behavior

% Conduct statistical analyses on behavioral data 
run behavior_stats.m

%% DDM

%########## Run hddm_buysell_final.py in Python %########## 

% Simulate choice and rt based on DDM estimates
run ddm_simulate.m

% Perform advanced statistical analyses on DDM outputs
run ddm_stats.m

%% Step 3: Eye
% Identify invalid eye data
run eye_trial.m

%% Step 4: Gaze
% Identify gaze data (gaze.csv) from eye.csv
run gaze_preprocess.m
% Calculate gaze information for each trial
run gaze_trial.m
% Perform statistical analyses on trial-level gaze data
run gaze_stats.m
% Plot gaze heatmap (2 hours)
run gaze_figure.m 

%% Step 5: aDDM
% Prepare data file for addm analysis
run gaze_trial_addm.m

%########## Run ahddm_buysell_final.py in Python %##########

% Perform advanced statistical analyses on aDDM outputs
run gaze_stats_addm.m

% Perform advanced statistical analyses on aDDM outputs with first gaze
run gaze_stats_addm_first_gaze.m

% Simulate choice and rt
run gaze_stats_addm_simulate.m

%% Step 6: Pupil
% Preprocess pupil data and generate a single pupil.csv
run pupil_preprocess.m
% Calculate pupil information for each trial
run pupil_trial.m
% Plot pupil curves
run pupil_figure.m
% Perform statistical analyses on trial-level pupil data
% &&&log&&&BetaPupil
run pupil_stats.m

%% PTM: logit model
run ptm_stats.m

%% Order effect
run order_stats.m

%%
clock
